<!--
 * @FilePath: /vue-ts/src/views/dashboard/dash.vue
 * @Author: Yongchao Wang
 * @Date: 2020-09-16 21:51:20
 * @LastEditors: Yongchao Wang
 * @LastEditTime: 2020-09-17 21:05:11
-->
<template>
    <a-layout id="components-layout-demo-custom-trigger" class="container">
    <a-layout-sider v-model="collapsed" :trigger="null" collapsible>
      <div class="logo" />
      <a-menu theme="dark" mode="inline" :default-selected-keys="['1']" @click="menuClick">
        <a-menu-item key="1">
        <a-icon type="form" />
        <span>添加文章</span>
        </a-menu-item>
        <a-menu-item key="2">
        <a-icon type="snippets" />
        <span>文章列表</span>
        </a-menu-item>
        <a-menu-item key="3">
        <a-icon type="picture" />
          <span>图片列表</span>
        </a-menu-item>
      </a-menu>
    </a-layout-sider>
    <a-layout>
      <a-layout-header style="background: #fff; padding: 0">
        <a-icon
          class="trigger"
          :type="collapsed ? 'menu-unfold' : 'menu-fold'"
          @click="() => (collapsed = !collapsed)"
        />
      </a-layout-header>
      <a-layout-content
        :style="{ margin: '24px 16px', padding: '24px', background: '#fff', minHeight: '280px' }"
      >
        <router-view></router-view>
      </a-layout-content>
    </a-layout>
  </a-layout>
</template>
<script lang='ts'>
import { Component, Vue } from 'vue-property-decorator';

@Component
export default class Dash extends Vue {
  collapsed = true

  curentIndex = '1'

  menuClick(e: any) {
    if (this.curentIndex === e.key) {
      return;
    }
    this.curentIndex = e.key;
    switch (e.key) {
      case '1':
        this.$router.push('/addarticle');
        break;
      case '2':
        this.$router.push('/articlelist');
        break;
      default:
        this.$router.push('/photo');

        break;
    }
  }
}
</script>
<style>
#components-layout-demo-custom-trigger .trigger {
  font-size: 18px;
  line-height: 64px;
  padding: 0 24px;
  cursor: pointer;
  transition: color 0.3s;
}

#components-layout-demo-custom-trigger .trigger:hover {
  color: #1890ff;
}

#components-layout-demo-custom-trigger .logo {
  height: 32px;
  background: url(../../assets/logo.png) no-repeat  center ;
  background-size: auto 100% ;
  margin: 16px;
}
.container{
  height: 100%;
}
</style>
